// components/AuthRoute.tsx//路由守卫组件
import { useAuth } from '@/hooks/useAuth';
import { ReactNode, useEffect } from 'react';

interface AuthRouteProps {
  children?: ReactNode;
}

const AuthRoute = ({ children }: AuthRouteProps) => {
  const { requireAuth } = useAuth();

  useEffect(() => {
    requireAuth();
  }, []);

  // 如果未登录，requireAuth 会重定向，这里不渲染内容
  // 如果已登录，渲染子组件
  return <>{children}</>;
};

export default AuthRoute;